package com.example.mybaseapp.widget

import android.content.Context
import android.graphics.Canvas
import android.graphics.Paint
import android.util.AttributeSet
import com.example.mybaseapp.R

class SemiCircleSeekBar(context: Context, attrs: AttributeSet) : androidx.appcompat.widget.AppCompatSeekBar(context, attrs) {

    override fun onDraw(canvas: Canvas) {
        super.onDraw(canvas)

        val centerX = width / 2f
        val centerY = height.toFloat()

        val radius = width.coerceAtMost(height) / 2f
        val progressDegrees = progress.toFloat() / max * 180

        val startAngle = 180f
        val sweepAngle = 180f

        val paint = Paint().apply {
            isAntiAlias = true
            style = Paint.Style.STROKE
            strokeWidth = 10f // 设置进度条的宽度
            color = resources.getColor(R.color.purple_200,null) // 设置进度条的颜色
        }

        canvas.drawArc(centerX - radius, centerY - radius, centerX + radius, centerY + radius,
            startAngle, sweepAngle, false, paint)
    }
}